﻿//-----------------------------------------------------------------------
// <copyright file="Layouts.cs" company="LMT">
//     Copyright (c) by La Minh Thuận.
// </copyright>
// <author>thuanla1985@hotmail.com</author>
//-----------------------------------------------------------------------
namespace LMT.Forms.Text
{
    using System;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    /// <summary>
    /// Formating text layout for control
    /// </summary>
    internal class Layouts
    {
        /// <summary>
        /// Prevents a default instance of the Layouts class from being created
        /// </summary>
        private Layouts()
        {
        }

        /// <summary>
        /// Parses the alignment from DataGridViewContentAlignment
        /// </summary>
        /// <param name="align">The align.</param>
        /// <returns>StringFormat is used for drawing.</returns>
        internal static StringFormat ParseAlignment(DataGridViewContentAlignment align)
        {
            StringFormat sF = new StringFormat();

            if (align == DataGridViewContentAlignment.TopLeft)
            {
                sF.Alignment = StringAlignment.Near;
                sF.LineAlignment = StringAlignment.Near;
            }
            else if (align == DataGridViewContentAlignment.TopCenter)
            {
                sF.Alignment = StringAlignment.Center;
                sF.LineAlignment = StringAlignment.Near;
            }
            else if (align == DataGridViewContentAlignment.TopRight)
            {
                sF.Alignment = StringAlignment.Far;
                sF.LineAlignment = StringAlignment.Near;
            }
            else if (align == DataGridViewContentAlignment.MiddleLeft)
            {
                sF.Alignment = StringAlignment.Near;
                sF.LineAlignment = StringAlignment.Center;
            }
            else if (align == DataGridViewContentAlignment.MiddleCenter)
            {
                sF.Alignment = StringAlignment.Center;
                sF.LineAlignment = StringAlignment.Center;
            }
            else if (align == DataGridViewContentAlignment.MiddleRight)
            {
                sF.Alignment = StringAlignment.Far;
                sF.LineAlignment = StringAlignment.Center;
            }
            else if (align == DataGridViewContentAlignment.BottomLeft)
            {
                sF.Alignment = StringAlignment.Near;
                sF.LineAlignment = StringAlignment.Far;
            }
            else if (align == DataGridViewContentAlignment.BottomCenter)
            {
                sF.Alignment = StringAlignment.Center;
                sF.LineAlignment = StringAlignment.Far;
            }
            else if (align == DataGridViewContentAlignment.BottomRight)
            {
                sF.Alignment = StringAlignment.Far;
                sF.LineAlignment = StringAlignment.Far;
            }

            return sF;
        }
    }
}
